home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1995 November
/
EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso
/
earcd
/
util
/
cli
/
0utils.lha
/
0Utils
/
GetWord.data
< prev
next >
Wrap
Text File
|
1995-08-19
|
2KB
|
89 lines
#ifdef TPLTER
GetWord = {
SHORT = {{ get one in a list of words }};
DESCRIPTION = {{
get a number and a couple of strings and
find the n-th string starting with 1.
Negative numbers cause counting with the
last word.
The resulting string is sent to STDOUT.
Numbers, that exceed the number of words,
result in a returncode "10" (so does number=0)
RESULT
word [number-1]
}};
BUGS = {{
there are problems, if GetWord is invoked with
wrong word number in Scripts: for unknown reason
the secondary result is cleared early.
(see .KnownBugs)
The documentation wrongly stated a returncode 9
on wrong numbers.
}};
EXAMPLES = {{
>GetWord 1 ali baba
"ali"
>GetWord -1 ali baba
"baba"
>GetWord 3 ali baba
"GetWord: bad number"
}};
HISTORY = {{
01-08-93 b_noll created
23-08-93 b_noll completed
11-02-95 b_noll slight changes
20-02-95 b_noll restructured source
21-02-95 b_noll added version/format-prefix/offset
20-03-95 b_noll added args diagnostics
19-08-95 b_noll created .data file
}};
Template = "NUMBER/N/A,WORDS/M";
Arguments = {{
LONG * num;
STRPTR* words;
}};
version = "1.3";
body = {{
long num, cnt;
for (cnt = 0; argv->words[cnt]; ++cnt);
num = *(argv->num);
if (num < 0) num += cnt+1;
//retval = RETURN_WARN; /* if no error is wanted ... */
if (num == 0 || num > cnt) {
SetIoErr (ERROR_BAD_NUMBER);
} else {
retval = RETURN_WARN;
if (PutStr (argv->words[num-1]) == 0) retval = RETURN_OK;
PutStr("\n");
} /* if */
}};
};
#endif